// pages/update/update.js
Page({
  data: {
    infos: [],
    info: {},
    index: 0
  },
  onLoad: function (options) {
    var Infos = wx.getStorageSync('INFOS').infos
    this.setData({
      infos: Infos,
      info: Infos[options.index],
      index: options.index
    });
  },
  formSubmit: function (e) {
    var Desc = e.detail.value.desc;
    this.data.info.desc = Desc;
    this.setData({
      info: this.data.info
    });
    this.data.infos[this.data.index] = this.data.info;
    wx.setStorageSync("INFOS", this.data);
    wx.showToast({
      title: '修改成功',
      icon: 'success',
      duration: 1000
    });
  },
  del: function () {
    this.data.infos.splice(this.data.index, 1);
    wx.setStorageSync("INFOS", this.data);
    wx.showToast({
      title: '删除成功',
      icon: 'success',
      duration: 1000,
      complete: function () {
        setTimeout(function () {
          wx.navigateTo({
            url: '../abook/abook'
          });
        }, 800);
      }
    });
  }
})